import request from './request'
//看接口文档传参(同名可省略)
const key = '433435ba22462e523fef8b4a65336fa5'
//通过 ip 地址查询所在城市(不传ip默认查询本机ip)
export const getCityIp = () => {
  return request({
    url: '/ip?',
    params: {
      key,
    },
  })
}
//通过城市名查询adcode
export const getAdcode = (address) => {
  return request({
    url: '/geocode/geo?',
    params: {
      address,
      key,
      output: 'json',
    },
  })
}
//根据用户输入的搜索条件可以帮助用户快速的查找特定的行政区域信息。
export const getSearch = (keywords) => {
  return request({
    url: '/config/district?',
    params: {
      keywords,
      key,
      output: 'json',
    },
  })
}

//通过adcode查询天气
export const getWeather = (adcode, type) => {
  return request({
    url: '/weather/weatherInfo?',
    params: {
      city: adcode,
      key,
      extensions: type,
      output: 'json',
    },
  })
}
